//
//
//
//
//
//
//

#include "common.h"
#include "Condition.h"

Condition::Condition()
{
	pthread_mutex_init(&_mutex, NULL);
	pthread_cond_init(&_cond, NULL);
}

Condition::~Condition()
{
	pthread_mutex_destroy(&_mutex);
	pthread_cond_destroy(&_cond);
}

bool Condition::CondWait(void)
{
	return pthread_cond_wait(&_cond, &_mutex) == 0 ? true : false;
}

bool Condition::Signal(U32 count)
{
	for(U32 i = 0; i < count ; i++)
	{
		pthread_cond_signal(&_cond);
	}
	return true;
}


bool Condition::Broadcast()
{
	return pthread_cond_broadcast(&_cond) == 0 ? true : false;
}
